package com.gym.emp.services.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gym.emp.dao.EmpMapper;
import com.gym.emp.entity.Emp;
import com.gym.emp.services.EmpServices;
import com.gym.emp.util.MybatisUtils;

import java.util.List;

/**
 * @author ming
 * 2021/11/10
 * description:
 */
public class EmpServicesImpl implements EmpServices {

    @Override
    public List<Emp> getAll() {
        EmpMapper mapper = MybatisUtils.getMapper(EmpMapper.class);
        List<Emp> all = mapper.getAll();
        MybatisUtils.commit();
        return all;
    }

    @Override
    public PageInfo<Emp> getEmpByPages(int pageIndex) {
        EmpMapper mapper = MybatisUtils.getMapper(EmpMapper.class);
        PageHelper.startPage(pageIndex,5);
        List<Emp> all = mapper.getAll();
        PageInfo<Emp> emps = new PageInfo<>(all);
        return emps;
    }
}
